

import Category from "./CateEnum"

class ItemData{
    id?:number
    categoryId?:Category
    title?:string
    content?:string
    createTime?:string

    constructor(id:number=-1,categoryId:Category=-1,title:string='',content:string=''){
        this.id = id
        //在此使用枚举类型  代表  笔记分类
        this.categoryId = categoryId
        this.title = title
        this.content = content
        this.createTime = this.toSelfDateStr(Date.now())

    }

    toSelfDateStr(timeSpan:number):string{
        //时间戳转日期对象
        let date = new Date(timeSpan)
        //拼接日期
        let str = date.getFullYear() + '-' + (date.getMonth()+1) + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes()
        return str 
    }


}


export default ItemData